#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>

int main()
{
    key_t key = ftok(".", 1);
    int shmid = shmget(key, 4096, IPC_CREAT | IPC_EXCL | 0666);

    char *ptr = (char *)shmat(shmid, nullptr, 0);

    for (int ch = 'a'; ch <= 'z'; ch++)
    {
        ptr[ch - 'a'] = ch;
        sleep(1);
    }

    shmdt(ptr);
    shmctl(shmid, IPC_RMID, nullptr);

    return 0;
}